package org.agony2d.gpu.supportClasses.textures {
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	import org.agony2d.debug.Logger;
	import org.agony2d.core.agony_internal;
	
	use namespace agony_internal;
	
public class TextureManager {
	
	agony_internal static function addFullTexture( name:String, data:BitmapData, mipmapEnabled:Boolean, optimizeForRenderToTexture:Boolean ) : void {
		var fullTexture:FullTexture
		
		fullTexture = g_textureList[name]
		if(!fullTexture){
			fullTexture = g_textureList[name] = new FullTexture(name)
		}
		fullTexture.reset(data, mipmapEnabled, optimizeForRenderToTexture)
	}
	
	agony_internal static function addRegionTexture( fullTextureName:String, regionName:String, regionRect:Rectangle ) : void {
		var fullTexture:FullTexture
		
		fullTexture = g_textureList[fullTextureName]
		if (!fullTexture) {
			Logger.reportError("TextureManager", "addRegionTexture", "non existed full texture [ " + fullTextureName + " ]...")
		}
		fullTexture.addRegion(regionName, regionRect)
	}
	
	agony_internal static function removeTexture( fullTextureName:String ) : void {
		var texture:TextureProxy
		
		texture = g_textureList[fullTextureName]
		if (texture) {
			texture.dispose()
			delete g_textureList[fullTextureName]
		}
	}
	
	
	agony_internal static var g_textureList:Object
}
}